#ifndef _HAL_PWM_H
#define _HAL_PWM_H
#include "ch32v20x.h"
#include "hal_gpio.h"
#include <stdint.h>

#define   HAL_DEFAULT_PWM_MODE      TIM_OCMode_PWM1      
#define   HAL_TIM_TYPE              TIM_TypeDef


enum HAL_PWM_CHANNEL{
    HAL_OC1 = 0,
    HAL_OC2,
    HAL_OC3,
    HAL_OC4,    
};

struct hal_pwm_type{
    HAL_TIM_TYPE *tim;
    struct gpio_type *pin;
    uint32_t frq;
    void (*callback)(void);
    uint8_t  duty;
    uint8_t  channel;

};
void hal_pwm_init(struct hal_pwm_type *pwm);
void hal_pwm_start(struct hal_pwm_type *pwm);
void hal_pwm_pause(struct hal_pwm_type *pwm);
void hal_pwm_set_duty(struct hal_pwm_type *pwm,uint8_t duty);
#endif